import { h, render, defineComponent } from "vue";
import Container from "./index.vue";

/**
 * @param {*} title 标题
 * @param {*} content 内容
 * @param {*} cancelText 取消文本
 * @param {*} confirmText 确认文本
 */
export default class InfoBox {
  constructor({ el, positionLeft, contentId, positionTop, slot }) {
    this._parentDom = document.getElementById(el);
    this.contentId = contentId;
    this.init(positionLeft, positionTop, slot);
  }
  // 初始化
  init(positionLeft, positionTop, slot) {
    // 生成vnode 节点
    this.vnode = h(
      Container,
      {
        left: positionLeft,
        top: positionTop,
        id: this.contentId,
      },
      {
        default: () => h(slot), // 插槽
      }
    );
    // 渲染到父节点上
    render(this.vnode, this._parentDom);
  }
  close = () => {
    render(null, this._parentDom);
  };
  show = () => {};
}
